#include <stdio.h>
#include <string.h>

char trees[10001] = {0};
// 1 : have tree
// 0 : cut

void plant(unsigned len)
{
    memset(trees, 1, len + 1);
}

void cut(unsigned start, unsigned end)
{
    memset(trees + start, 0, end - start + 1);
}

unsigned len = 0, takes = 0;

int main()
{
    scanf("%u%u", &len, &takes);
    plant(len);
    for (int i = 0; i < takes; ++i)
    {
        unsigned a, b;
        scanf("%u%u", &a, &b);
        cut(a, b);
    }
    unsigned sum = 0;
    for (int i = 0; i < 10001; ++i)
    {
        sum += trees[i];
    }
    printf("%d ", sum);
    return 0;
}